<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="admin/_fragments :: head(~{::title})">
    <!--th:replace="admin/_fragments :: head(~{::title})"-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.17.1/themes/prism.min.css">
    <link rel="stylesheet" href="../../static/css/me.css" th:href="@{/css/me.css}">
    <link rel="stylesheet" href="../../static/semantis-ui/semantic.min.css">
    <link rel="stylesheet" href="../../static/lib/editormd/css/editormd.min.css" th:href="@{/css/editormd.min.css}">
    <script src="../../static/semantis-ui/jquery-3.6.0.js" th:src="@{/semantis-ui/jquery-3.6.0.js}"></script>
    <script src="../../static/semantis-ui/semantic.min.js" th:src="@{/semantis-ui/semantic.min.js}"></script>

    <!--引入的Markdown编辑器-->
    <script src="../../static/lib/editormd/editormd.min.js" th:src="@{/editormd/editormd.min.js}"></script>
    <title>博客发布</title>
</head>
<body>
<!--导航-->
<!--segment反转 inverted平铺 导航栏-->
<nav class="ui segment inverted attached segment me-padded-tb-mini bg">
    <!--放在一个container中-->
    <div class="ui container ">
        <!--里面的菜单   stackable适应手机-->
        <div class="ui inverted stackable menu bg">
            <h2 class="ui teal header item ">HJ&nbsp&nbspblog</h2>
            <a href="#" th:href="@{/admin/blogs}" class="m-item item m-mobile-hide"><i class="m-margin-tb-menu icon home"></i>首页</a>
            <a href="#" th:href="@{/admin/types}" class="m-item item m-mobile-hide"><i class="m-margin-tb-menu folder open outline icon"></i>分类</a>
            <a href="#" th:href="@{/admin/tags}"  class="m-item item m-mobile-hide"><i class="m-margin-tb-menu edit outline icon"></i>标签</a>
            <div class="right menu">
                <div class="ui dropdown item" th:replace="admin/_fragments :: content">
                    <div class="text">
                        <img src="../../static/image/小.png" alt="" class="ui avatar image">
                        王锡豪
                    </div>
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="#" class="item">注销</a>
                    </div>


                </div>
            </div>

        </div>
    </div>
    <!--三条杠 更多按钮-->
    <a href="#" class="ui icon button menu toggle m-right-top bg white-font m-mobile-show">
        <i class="sidebar icon"></i>
    </a>
</nav>
<div class="ui attached pointing menu">
    <div class="ui container">
        <div class="right menu">

            <a href="#" class="active item">发布</a>
            <a href="#" class="item">列表</a>

        </div>

    </div>
</div>


<!--中间-->
<div class="m-padded-d-mass">
    <div class="m-container-small m-padded-tb-big">
        <div class="ui container">
            <!--header -->
            <form action="#" id="blog-form" th:object="${blog}" th:action="@{/admin/blogs}" method="post" class="ui form">
                <input type="hidden" name="published">
                <input type="hidden" name="id" th:value="*{id}">
                <!--required不输入会变红-->
                <div class="required field">
                    <div class="ui left labeled input">
                        <div class="ui selection compact teal basic dropdown label">
                            <input type="hidden"  name="flag" th:value="*{flag} != null ? *{flag} : 原创">
                            <i class="dropdown icon"></i>
                            <div class="text">原创</div>
                            <div class="menu">
                                <div class="item" data-value="原创">原创</div>
                                <div class="item" data-value="转载">转载</div>
                                <div class="item" data-value="翻译">翻译</div>
                            </div>
                        </div>
                        <input type="text" name="title" placeholder="请选择标题" th:value="*{title}">
                    </div>
                </div>

                <div class="field required">
                    <!--里面加入一个Markdown编辑器-->
                    <div id="test-editormd" style="z-index: 1 !important;">
                        <textarea placeholder="博客内容...(小提示：前两行尽量要写成描述哦！这样才会更容易被找到。)" name="content" style="display:none;" th:text="*{content}">[TOC]

#### Disabled options

- TeX (Based on KaTeX);
- Emoji;
- Task lists;
- HTML tags decode;
- Flowchart and Sequence Diagram;

#### Editor.md directory

    editor.md/
            lib/
            css/
            scss/
            tests/
            fonts/
            images/
            plugins/
            examples/
            languages/
            editormd.js
            ...

```html
</textarea>

                    </div>
                </div>

                <div class="two fields">
                    <div class="field">
                        <div class="ui required left labeled action input">
                            <label class="ui compact teal basic label">分类</label>
                            <div class="ui fluid selection dropdown">
                                <input type="hidden" name="type.id" th:value="*{type} != null ? *{type.id}">
                                <i class="dropdown icon"></i>
                                <div class="default text">分类</div>
                                <div class="menu">
                                    <!--<div class="item" data-value="1">错误日志</div>-->
                                    <!--从后台拿动态数据-->
                                    <div th:each="type : ${types}" class="item" data-value="1" th:data-value="${type.id}" th:text="${type.name}">错误日志
                                    </div>
                                    <!--<div class="item" data-value="2">开发者手册</div>-->
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui left labeled action input">

                            <label class="ui compact teal basic label">标签</label>
                            <div class="ui fluid multiple search selection dropdown">
                                <!--multiple search选择和搜索的下拉框-->
                                <!-- 隐含域将两个联系起来    tagIds的类型value="1,2,3"-->
                                <input type="hidden" name="tagIds" th:value="*{tagIds}">
                                <i class="dropdown icon"></i>
                                <div class="default text" >标签</div>
                                <div class="menu">
                                    <div th:each="tag : ${tags}" class="item" data-value="1" th:data-value="${tag.id}" th:text="${tag.name}">
                                        Java
                                    </div>

                                    <!--<div class="item" data-value="1">Java</div>-->
                                    <!--<div class="item" data-value="2">JavaScript</div>-->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="field required">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label">首图</label>
                        <input type="text" name="firstPicture" th:value="*{firstPicture}" placeholder="首图引用地址">
                    </div>
                </div>


                <div class="inline fields">
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="recommend" name="recommend" class="hidden" th:checked="*{recommend}"><label
                                for="recommend">推荐</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="shareStatement" name="shareStatement" class="hidden" th:checked="*{shareStatement}"><label
                                for="shareStatement">转载声明</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="appreciation" name="appreciation" class="hidden" th:checked="*{appreciation}"><label
                                for="appreciation">赞赏</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="commentabled" name="commentabled" class="hidden" th:checked="*{commentabled}"><label
                                for="commentabled">评论</label>
                        </div>
                    </div>
                </div>
                <!--错误信息-->
                <div class="ui error message">

                </div>

                <div class="ui right aligned container">
                    <button type="button" class="ui button" onclick="window. history.go(-1)">返回</button>
                    <button type="button" id="save-btn" class="ui secondary button">保存</button>
                    <button type="button" id="publish-btn" class="ui teal button">发布</button>
                </div>

            </form>


        </div>
    </div>


    <br/>
</div>

<!--底部      m-padded-d-mass间隔-->
<footer class="ui segment inverted vertical segment m-padded-d-mass bg">
    <!--container容器 center aligned居中-->
    <div class="ui center aligned container bg">
        <!--grid会把一些布局分为12列  devided加线 -->
        <div class="ui inverted divided grid bg">
            <div class="three wide column m-opacity-mini m-text-space m-text-thin m-text-lined">
                <div class="ui inverted link list bg">
                    <img src="./static/image/wo.jpg" alt="" class="ui rounded image" style="width:110px">

                </div>
            </div>
            <div class="three wide column m-opacity-mini m-text-space m-text-thin m-text-lined">
                <h4 class="ui inverted header">最新博客</h4>
                <div class="ui inverted link list ">
                    <a href="#" class="item">会飞的羊</a>
                    <a href="#" class="item">会飞的羊</a>
                    <a href="#" class="item">会飞的羊</a>
                </div>
            </div>
            <div class="three wide column m-opacity-mini m-text-space m-text-thin m-text-lined">
                <h4 class="ui inverted header">联系我吖</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">QQ:822021336</a>
                    <a href="#" class="item">邮箱：xihao.luck@qq.com</a>
                    <a href="#" class="item"></a>
                </div>
            </div>
            <div class="seven wide column">
                <h4 class="ui inverted header m-opacity-mini m-text-space m-text-thin m-text-lined">最新博客</h4>
                <p class="m-opacity-mini m-text-space m-text-thin m-text-lined">
                    这是我的个人博客，用于记录我在网上收集的文章，自己的代码笔记，和优秀的文案等等。欢迎大家关注！</p>
            </div>
        </div>
        <div class="ui inverted section divider m-opacity-mini m-text-space m-text-thin m-text-lined "></div>
        <p class="m-opacity-mini m-text-space m-text-thin m-text-lined">Copyright © 2021-2022 会飞的羊 </p>
    </div>

</footer>

<!--jquery-->
<script>


    // <!--
    // 初始化Markdown-->
    // var testEditor;
    //
    // $(function () {
    //     testEditor = editormd("test-editormd", {
    //         width: "100%",
    //         height: 640,
    //         syncScrolling: "single",
    //         path: "../../static/lib/editormd/lib/"
    //     });
    //
    //     /*
    //     // or
    //     testEditor = editormd({
    //         id      : "test-editormd",
    //         width   : "90%",
    //         height  : 640,
    //         path    : "../lib/"
    //     });
    //     */
    // });


    <!--点击.menu.toggle按钮加入m-mobile-hide样式-->
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide')
    });

    $('.ui.dropdown')
        .dropdown();

    $('.ui.form').form({
        fields: {
            //指定name为title区域
            title: {
                //identifier:'title',寻找name为title的框
                identifier: 'title',
                rules: [{
                    type: 'empty',
                    prompt: '标题：请输入博客标题'
                }]
            },
            content: {
                //identifier:'title',寻找name为title的框
                identifier: 'content',
                rules: [{
                    type: 'empty',
                    prompt: '请输入博客内容'
                }]
            },
            typeId: {
                //identifier:'title',寻找name为title的框
                identifier: 'typeId',
                rules: [{
                    type: 'empty',
                    prompt: '请选择博客分类'
                }]
            },
            firstPicture: {
                //identifier:'title',寻找name为title的框
                identifier: 'firstPicture',
                rules: [{
                    type: 'empty',
                    prompt: '请输入博客首图'
                }]
            }
        }
    });
    //点击保存按钮将 published赋值为fallse
    //提交blog-form
    $('#save-btn').click(function () {
        $('[name=published]').val(false);
        $('#blog-form').submit();
    });
    //点击保存按钮将
    //提交blog-formpublished赋值为fallse
    $('#publish-btn').click(function () {
        $('[name=published]').val(true);
        $('#blog-form').submit();
    });
</script>
<!--不能写在上面的script  特么的找了一上午-->
<script type="text/javascript">
    var testEditor;
    $(function () {
        testEditor = editormd("test-editormd", {
            width: "100%",
            height: 640,
            syncScrolling: "single",
            path: "/lib/editormd/lib/"
        });

        /*
        // or
        testEditor = editormd({
            id      : "test-editormd",
            width   : "90%",
            height  : 640,
            path    : "../lib/"
        });
        */
    });
</script>

</body>
</html>